package bth.reconfs;

import java.util.Locale;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class Itinerary extends ActionBarActivity{

	private Button butTravel;
	private Button butHotel;
	private ActionBar actionBar;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.itinerary);

		butTravel = (Button) findViewById(R.id.travel_informations);
		butTravel.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent travel = new Intent(Itinerary.this, Travel.class);
				startActivityForResult(travel, 21);
			}
		});	

		butHotel = (Button) findViewById(R.id.hotels);
		butHotel.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent hotels = new Intent(Itinerary.this, Hotels.class);
				startActivityForResult(hotels, 22);
			}
		});

		actionBar = getSupportActionBar();
		actionBar.setHomeButtonEnabled(true);
	}

	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.maps, menu);
		return true;
	}

	public boolean onOptionsItemSelected(MenuItem item) {
		final int id = item.getItemId();
		switch (id) {
		case R.id.show_bth_in_maps:
			String uri = String.format(Locale.ENGLISH, "geo:%f,%f?z=%d&q=%s", 56.182307, 15.590715, 17, "Blekinge Institute of Technology");//latitude, longitude, zoom, label
			Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
			this.startActivity(intent);
			return true;
		}
		return false;
	}
}